home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
machserver
/
1.098
/
dev
/
scsiDevice.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-11
|
7KB
|
163 lines
/*
* scsiDevice.h --
*
* Declarations of Sprite interface to SCSI devices.
* This file defines the interface to SCSI devices which consists
* of three operations: Attach the device, Release the device, and
* send a SCSI command block to the device.
*
* INTERFACE SUMMARY:
*
* To interface to a SCSI device, the SCSI command formatter must first
* attach the device. This is done by calling DevScsiAttachDevice() with
* the Fs_Device structure for the device. DevScsiAttachDevice
* returns a ScsiDeviceHandle that contains the queue to insert
* scsi command blocks for the device. The handle also
* contains the procedure to call to release the device.
*
*
* Copyright 1989 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*
* $Header: /sprite/src/kernel/dev/RCS/scsiDevice.h,v 9.1 90/09/11 12:13:37 rab Exp $ SPRITE (Berkeley)
*/
#ifndef _SCSIDEVICE
#define _SCSIDEVICE
#include "list.h"
#include "devQueue.h"
#include "user/fs.h"
#include "fs.h"
/*
* A device attached to a SCSI Bus is described by the following stucture.
* A pointer to a ScsiDevice is returned by the DevScsiAttachDevice
* routine and contains the device queue to use to
* send commands to the device. The fields of the structure are
* initialize by the attached routine and should not be modified or copied
* by the SCSI formatting routines. The pointer passed to the
* and releaseProc procedures should be the same value returned by the
* attachProc.
*/
typedef struct ScsiDevice {
DevQueue devQueue; /* Queue to send request for this
* device. Once the request has been
* processed, the caller
* caller by calling function sepcified
* in the SCSICmd structure. */
char *locationName; /* A string used to identify the device's
* location in error messages produced
* the SCSI formatting routines. An
* Example would be:
* "HBA 2 Bus 1 Target 6 LUN 2". */
int LUN; /* SCSI Logical unit number of device.
* This is stored here because the
* SCSI command formatter needs to
* know the LUN to build command
* blocks. */
ReturnStatus (*releaseProc)(); /* Routine to release the system
* resources used by the device. Calling
* sequence defined below. */
int maxTransferSize; /* Maximum size of data transfer to
* this device supported by the HBA. */
int inquiryLength; /* Length in bytes of the inquiryData
* pointed to by inquiryDataPtr. */
char *inquiryDataPtr; /* Data return by the INQUIRY command
* sent to the device. */
int referenceCount; /* Count of number of references to this
* device handle. */
} ScsiDevice;
/*
* The ScsiCmd data structure contains the information that a SCSI device
* to execute a SCSI command. It is the object enqueue on a SCSI device's
* request queue. Note that the bytes of the SCSI command block over 16
* bytes directly follow this data structure.
*/
struct ScsiCmd {
List_Links queuePtr; /* List for queueing in HBA. Because we
* use the DevQueue routines this element
* MUST be the first in the structure. */
Boolean dataToDevice; /* TRUE -> data is transferred to the device.
* FALSE -> data is transferred from the device.
* Meaningless if bufferLen is 0. */
int bufferLen; /* The length of the data buffer in bytes. */
Address buffer; /* The data buffer for this command. */
int (*doneProc)(); /* Routine to called when command completes.
* See below for its calling sequence. */
ClientData clientData; /* A word of data available to the caller.
* This item is not changed by the Device. */
int commandBlockLen; /* Length of the SCSI command block. The
* data of the SCSI command block immediately
* follows this data structure and continues
* for commandBlockLen bytes. */
char commandBlock[16]; /* The first 16 bytes of the SCSI command
* block. The rest of the command directly
* follows the first 16 bytes. */
};
typedef struct ScsiCmd ScsiCmd;
/*
* Upon command completion the routine specified by doneProc in the
* ScsiCmd data structure is called with the following arguments:
* (*doneProc)(scsiCmdPtr, errorCode, scsiStatusByte,
* amountTransferred, senseDataLen, senseDataPtr);
* where
* ScsiCmd *scsiCmdPtr - The scsiCmdPtr argument passed to sendCmdProc.
* ReturnStatus errorCode - The error code from the HBA.
* unsigned char scsiStatusByte - The scsi status byte as returned by the SCSI
* command.
* int amountTransferred - Number of bytes of data transferred by this
* command.
* int senseDataLen - The length in bytes of the SCSI sense info returned.
* This number will be zero useless the scsiStatusByte
* has the SCSI check condition bit set.
* char *senseDataPtr - Pointer to scsi sense blocks. This block will no
* longer be valid once the call back routine returns.
* (i.e. You must copy it if you want to save it.)
*
* scsiDoneProc may be called at interrupt level so it should use
* appropriate locking and be relatively simple. Also, scsiDoneProc
* maybe called before the sendCmdProc proc returns.
*/
/*
* DevScsiSendCmd is normally encoded as macros for speed and reduced
* calling depth.
* If lint is being run we use the real routines in devScsiDevice.c to
* permit type checking. Documentation on the calling sequence is found
* in devScsiDevice.c.
*/
#ifndef lint
#define DevScsiSendCmd(handlePtr, scsiCmdPtr) \
(Dev_QueueInsert((handlePtr)->devQueue,(List_Links *) (scsiCmdPtr)))
#else
extern void DevScsiSendCmd();
#endif
extern ScsiDevice *DevScsiAttachDevice _ARGS_((Fs_Device *devicePtr,
void (*insertProc)()));
extern ReturnStatus DevScsiSendCmdSync _ARGS_((ScsiDevice *scsiDevicePtr,
ScsiCmd *scsiCmdPtr, unsigned char *statusBytePtr,
int *amountTransferredPtr, int *senseBufferLenPtr, Address senseBufferPtr));
extern ReturnStatus DevScsiReleaseDevice _ARGS_((ScsiDevice *scsiDevicePtr));
extern ReturnStatus DevScsiTestReady _ARGS_((ScsiDevice *scsiDevicePtr));
extern ReturnStatus DevScsiStartStopUnit _ARGS_((ScsiDevice *scsiDevicePtr,
Boolean start));
extern ReturnStatus DevScsiIOControl _ARGS_((ScsiDevice *devPtr,
Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
extern ScsiDevice *DevNoHBAAttachDevice _ARGS_((Fs_Device *devicePtr,
void (*insertProc)()));
#endif /* _SCSIDEVICE */